#!/bin/bash

DATE=`date +%Y_%m_%d`
DB_USER="mongodb"
DB_PASSWD="pass562"

if [ -z $1 ]; then
echo "ERROR: please specify a database name"
exit 1
fi

#Restore the specified  database
mongorestore -u $DB_USER -p $DB_PASSWD -d $1 --directoryperdb /opt/mongod_bak/mongod_bak_now/$DATE/$1/

if [ $? -ne 0 ]; then
   echo "Restore database $1 error,please re-check!"
   exit 1
else
   echo "Restore database $ success!"
fi
